package com.zhxl.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zhxl.server.model.GoodsOrderItem;

@Mapper
public interface GoodsOrderItemDao {

    @Select("select * from goods_order_item t where t.id = #{id}")
    List<GoodsOrderItem> getById(Long id);

    @Select("select * from goods_order_item t where t.goods_order_id = #{id}")
    List<GoodsOrderItem> getByOrderId(Long id);

    @Delete("delete from goods_order_item where id = #{id}")
    int delete(Long id);

    int update(GoodsOrderItem goodsOrderItem);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into goods_order_item(goods_id, goods_order_id, name, specification, price, num, total_fee, pic_path) values(#{goodsId}, #{goodsOrderId}, #{name}, #{specification}, #{price}, #{num}, #{totalFee}, #{picPath})")
    int save(GoodsOrderItem goodsOrderItem);
    
    int count(@Param("params") Map<String, Object> params);

    List<GoodsOrderItem> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

//    @Select("select * from goods_order_item t where t.goods_order_id = #{id}")
//    List<GoodsOrderItem> getByOrderId(Long id);
}
